<template>
  <el-dropdown trigger="click" @command="changeLanguage">
    <i :class="'iconfont icon-anheimoshi'" class="toolBar-icon"></i>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item
          v-for="item in languageList"
          :key="item.value"
          :command="item.value"
          :disabled="language === item.value"
        >
          {{ item.label }}
        </el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<script setup lang="ts">
import { computed } from "vue";
import { useGlobalStore } from "@/stores/modules/global";
import { useTheme } from "@/hooks/useTheme";

const { switchDark } = useTheme();

const globalStore = useGlobalStore();
const language = computed(() => (globalStore.isDark ? "深色" : "浅色"));

const languageList = [
  { label: "浅色", value: "浅色" },
  { label: "深色", value: "深色" }
];

const changeLanguage = (theme: string) => {
  globalStore.setGlobalState("isDark", theme === "深色");
  switchDark();
};
</script>
